# coding: utf-8
# author: donghao
# email: donghao.wang@mihoyo.com
import os
import pprint
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys


login_url = '''http://10.8.19.23:5000/?launchApp=SYNO.SDS.VideoStation.AppInstance#!libanime/N4IgNglgRgTghjAniAXCAFgewLYFMD6AbhACa6YC0ALCADQgDGcALrgOaZKogBmmYZGHRAAHOG1yoAjAF8gA'''


def login(user, password):
    # chrome_options = webdriver.ChromeOptions()
    # 使用headless无界面浏览器模式
    # chrome_options.add_argument('--headless')
    # chrome_options.add_argument('--disable-gpu')
    for k, v in os.environ.iteritems():
        os.environ.update({k: str(v)})
    driver = webdriver.Chrome()
    driver.get(login_url)
    time.sleep(0.5)
    driver.find_element_by_name('username').clear()
    driver.find_element_by_name('username').send_keys(user)
    driver.find_element_by_name('passwd').clear()
    driver.find_element_by_name('passwd').send_keys(password)
    driver.find_element_by_name('passwd').send_keys(Keys.ENTER)
    return driver


if __name__ == '__main__':
    driver = login('mihoyo', '123456')